import Vue from 'vue'
import Router from 'vue-router'
import HelloWorld from '@/components/HelloWorld'
import Comment from "@/components/Comment";

import App from '../pages/App.vue'
import Demo011 from '../pages/demo/demo011.vue'
import Demo012 from '../pages/demo/demo012.vue'

import Home from '../pages/home/home.vue'
import Configuration from '../pages/demo/configuration.vue'
import Event from '../pages/demo/event.vue'
import User from '../pages/demo/user.vue'
import HeadMerging from '../pages/demo/head-merging.vue'
import Demo from '../pages/home/demo.vue'
import Nine from '../pages/demo/nine.vue'
import ElementDemo from '../pages/demo/element-demo.vue'
import Pagination from '../pages/demo/pagination.vue'

Vue.use(Router)

const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

export default new Router({
  mode: 'history',
  routes: [
    {
      path: '/',
      name: 'HelloWorld',
      component: HelloWorld
    },
    {
      path: '/comment',
      name: 'Comment',
      component: Comment
    },
    {
      path: '/demo011',
      name: 'Demo011',
      component: Demo011
    },
    {
      path: '/demo012',
      name: 'Demo012',
      component: Demo012
    },
    {
      path: '/home',
      name: 'Home',
      component: Home,
      children: [
        {
          path: '/app',
          name: 'App',
          component: App
        },
        {
          path: '/configuration',
          name: 'Configuration',
          component: Configuration
        },
        {
          path: '/event',
          name: 'Event',
          component: Event
        },
        {
          path: '/user',
          name: 'User',
          component: User
        },
        {
          path: '/head-merging',
          name: 'HeadMerging',
          component: HeadMerging
        }

      ]
    },
    {
      path: '/demo',
      name: 'Demo',
      component: Demo
    },
    {
      path: '/nine',
      name: 'Nine',
      component: Nine
    },
    {
      path: '/element-demo',
      name: 'ElementDemo',
      component: ElementDemo
    },
    {
      path: '/pagination',
      name: 'Pagination',
      component: Pagination
    }

  ]
})
